package model

import (
	"gorm.io/gorm"
	__ "grpc/basic/proto"
)

// 审核
type Review struct {
	gorm.Model
	UserId  int    `gorm:"type:int" json:"userId"`
	VideoId int    `gorm:"type:int" json:"videoId"`
	Status  string `gorm:"type:varchar(10)" json:"status"`
	Reason  string `gorm:"type:varchar(50)" json:"reason"` //失败原因
}

func (r *Review) ListReview(db *gorm.DB) (list []*__.ListReview, err error) {
	err = db.Debug().Model(&Review{}).
		Select("reviews.id as reviewId", "users.username as username", "videos.title as title",
			"videos.content as content", "videos.image as image", "reviews.status as status", "reviews.reason as reason").
		Joins("left join users on users.id = reviews.user_id").
		Joins("left join videos on videos.id = reviews.video_id").
		Find(&list).Error
	return list, err
}
